home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 January / Disc 3 / Amethyst.iso / live / usr / lib / rpm-3.0.6 / find-lang.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2001-04-06  |  2.2 KB  |  96 lines

  1. #!/bin/sh
  2. #findlang - automagically generate list of language specific files
  3. #for inclusion in an rpm spec file.
  4. #This does assume that the *.mo files are under .../share/locale/...
  5. #Run with no arguments gets a usage message.
  6.  
  7. #findlang is copyright (c) 1998 by W. L. Estes <wlestes@uncg.edu>
  8.  
  9. #Redistribution and use of this software are hereby permitted for any
  10. #purpose as long as this notice and the above copyright notice remain
  11. #in tact and are included with any redistribution of this file or any
  12. #work based on this file.
  13.  
  14. #changes:
  15. # 1999-10-19 Artur Frysiak <wiget@pld.org.pl>
  16. #   * added support for GNOME help files
  17. #   * start support for KDE help files
  18.  
  19. usage () {
  20. cat <<EOF
  21.  
  22. Usage: $0 TOP_DIR PACKAGE_NAME [prefix]
  23.  
  24. where TOP_DIR is
  25. the top of the tree containing the files to be processed--should be
  26. \$RPM_BUILD_ROOT usually. TOP_DIR gets sed'd out of the output list.
  27. PACKAGE_NAME is the %{name} of the package. This should also be
  28. the basename of the .mo files.  the output is written to
  29. PACKAGE_NAME.lang unless \$3 is given in which case output is written
  30. to \$3.
  31. Additional options:
  32.   --with-gnome        find GNOME help files
  33.   --with-kde        find KDE help files (not implemented yet)
  34.   --without-mo        not find locales files
  35. EOF
  36. exit 1
  37. }
  38.  
  39. if [ -z "$1" ] ; then usage
  40. elif [ $1 = / ] ; then echo $0: expects non-/ argument for '$1' 1>&2
  41. elif [ ! -d $1 ] ; then
  42.  echo $0: $1: no such directory
  43.  exit 1
  44. else TOP_DIR="`echo $1|sed -e 's:/$::'`"
  45. fi
  46. shift
  47.  
  48. if [ -z "$1" ] ; then usage
  49. else NAME=$1
  50. fi
  51. shift
  52.  
  53. GNOME=#
  54. KDE=#
  55. MO=
  56. MO_NAME=$NAME.lang
  57.  
  58. while test $# -gt 0 ; do
  59.     case "${1}" in
  60.     --with-gnome )
  61.           GNOME=
  62.         shift
  63.         ;;
  64.     --with-kde )
  65.         KDE_HELP=
  66.         shift
  67.         ;;
  68.     --without-mo )
  69.         MO=#
  70.         shift
  71.         ;;
  72.     * )
  73.         MO_NAME=${1}
  74.         shift
  75.         ;;
  76.     esac
  77. done    
  78.  
  79. find $TOP_DIR -type f|sed '
  80. 1i\
  81. %defattr (644, root, root, 755)
  82. s:'"$TOP_DIR"'::
  83. '"$MO"'s:\(.*/share/locale/\)\([^/_]\+\)\(.*'"$NAME"'\.mo$\):%lang(\2) \1\2\3:
  84. '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%lang(\2) \1\2:
  85. s:^\([^%].*\)::
  86. s:%lang(C) ::
  87. ' > $MO_NAME
  88.  
  89. find $TOP_DIR -type d|sed '
  90. s:'"$TOP_DIR"'::
  91. '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'$\):%dir \1:
  92. '"$GNOME"'s:\(.*/gnome/help/'"$NAME"'/\)\([^/_]\+\):%dir %lang(\2) \1\2:
  93. s:^\([^%].*\)::
  94. s:%lang(C) ::
  95. ' >> $MO_NAME
  96.